//package com.ruoyi.framework.wechat;
//
//import com.ruoyi.common.utils.OsUtils;
//import com.ruoyi.common.utils.spring.SpringUtils;
//import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.chrome.ChromeOptions;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.util.ResourceUtils;
//
//import javax.annotation.PreDestroy;
//
//@Configuration
//public class SeleniumConfig {
//    @Bean
//    public ChromeDriver chromeDriver() {
//        try {
//            String chromePath = "";
//            if (OsUtils.isWindows()) {
//                chromePath = "/static/chrome/chromedriver32.exe";
//            }
//            String chromeDriverPath = ResourceUtils.getFile(chromePath).getCanonicalPath();
//            String chromeAbsPath = ResourceUtils.getFile("classpath:/static/chrome/chrome-win32/chrome.exe").getCanonicalPath();
//            System.setProperty("webdriver.chrome.driver", chromeDriverPath);
//            ChromeOptions options = new ChromeOptions();
//            options.setBinary(chromeAbsPath);
//            // 添加参数，禁用信息栏中的自动化软件控制提示
//            options.addArguments("disable-infobars");
////            options.addArguments("--headless");
//            options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
//            ChromeDriver driver = new ChromeDriver(options);
//            return driver;
//        } catch (Exception e) {
//            return null;
//        }
//    }
//
//    @PreDestroy
//    public void destory() {
//        ChromeDriver chromeDriver = SpringUtils.getBean(ChromeDriver.class);
//        if (chromeDriver != null) {
//            chromeDriver.quit();
//        }
//    }
//}